@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap');

* {
    box-sizing: border-box;
}

body {
    font-family: 'Roboto', sans-serif;
    margin: 0;
    height: 100vh;
    overflow: hidden;
}

h4 {
    font-size: 20px;
    margin: 5px;
    text-transform: uppercase;
}

.counter {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%); /* 这个也是移动距离 */
    text-align: center;
}

.counter.hide {
    transform: translate(-50%, -50%) scale(0); /* translate(x,x)是控制位置; scale(0)控制消失, 这里控制最后一个数字显示后消失的动画 */
    animation: hide 0.2s ease-out; /* 0.2 秒后执行退出动画 */
}

@keyframes hide {
    0% {
        transform: translate(-50%, -50%) scale(1); /* 同样的translate是控制位置显示到中间, scale显示动画 0 表示消失了 */
    }

    100% {
        transform: translate(-50%, -50%) scale(0);
    }
}

.final {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    text-align: center;
}

.final.show {
    transform: translate(-50%, -50%) scale(1); /* 和上面的消失动画相反, 这里是出现, 只要设置scale(1)即可 */
    animation: show 0.2s ease-out;
}

@keyframes show {
    0% {
        transform: translate(-50%, -50%) scale(0);
    }

    30% {
        transform: translate(-50%, -50%) scale(1.4);
    }

    100% {
        transform: translate(-50%, -50%) scale(1);
    }
}

.nums {
    color: #3498db;
    font-size: 50px;
    position: relative; /* 父亲相对布局nums; 子绝对布局 .nums span */
    overflow: hidden;
    width: 250px;
    height: 50px;
}

.nums span {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(120deg);
    transform-origin: bottom center;
}

.nums span.in {
    transform: translate(-50%, -50%) rotate(0deg); /*  transform: 旋转（rotate），缩放（scale），倾斜（skew），移动（translate） */
    animation: goIn 0.5s ease-in-out;
}

.nums span.out {
    animation: goOut 0.5s ease-in-out;
}

@keyframes goIn {
    0% {
        transform: translate(-50%, -50%) rotate(120deg);
    }

    30% {
        transform: translate(-50%, -50%) rotate(-20deg);
    }

    60% {
        transform: translate(-50%, -50%) rotate(10deg);
    }

    100% {
        transform: translate(-50%, -50%) rotate(0deg);
    }
}

@keyframes goOut {
    0% {
        transform: translate(-50%, -50%) rotate(0deg);
    }

    60% {
        transform: translate(-50%, -50%) rotate(20deg);
    }

    100% {
        transform: translate(-50%, -50%) rotate(-120deg);
    }
}

#replay{
    background-color: #3498db;
    border-radius: 3px;
    border: none;
    color: aliceblue;
    padding: 5px;
    text-align: center;
    display: inline-block;
    cursor: pointer;
    transition: all 0.3s;
}

#replay span{
    cursor: pointer;
    display: inline-block;
    position: relative;
    transition: 0.3s;
}

#replay span:after{
    content: '\00bb';
    position: absolute;
    opacity: 0;
    top: 0;
    right: -20px;
    transition: 0.5s;
}

#replay:hover span{
    padding-right: 25px;
}

#replay:hover span:after{
    opacity: 1; /* 1 实体, 0 透明看不到了 */
    right: 0;
}
